home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / convrtrs / pbmplus / update4.lha / src / extra / ppmtomitsu.c.orig < prev    next >
Encoding:
Text File  |  1993-03-31  |  19.4 KB  |  613 lines

  1. /* ppmtomitsu.c - read a portable pixmap and produce output for the
  2. **                Mitsubishi S340-10 Thermo-Sublimation Printer
  3. **                (or the S3410-30 parallel interface)
  4. **
  5. ** Copyright (C) 1992,93 by S.Petra Zeidler
  6. **
  7. ** This software was written for the Max Planck Institut fuer Radioastronomie,
  8. ** Bonn, Germany, Optical Interferometry group
  9. **
  10. ** Permission to use, copy, modify, and distribute this software and its
  11. ** documentation for any purpose and without fee is hereby granted, provided
  12. ** that the above copyright notice appear in all copies and that both that
  13. ** copyright notice and this permission notice appear in supporting
  14. ** documentation.  This software is provided "as is" without express or
  15. ** implied warranty.
  16. */
  17.  
  18. static char SCCSid[] = "@(#)ppmtomitsu.c\t\t1.8\t(SPZ)\t3/31/93\n";
  19. #include "ppm.h"
  20. #include "ppmcmap.h"
  21. #include "pbmplus.h"
  22. #include <memory.h>
  23. #include "mitsu.h"
  24.  
  25. #ifdef __STDC__
  26. void main(int argc, char *argv[] )
  27. #else
  28. void main( argc, argv )
  29.     int argc;
  30.     char* argv[];
  31. #endif
  32.     {
  33.     FILE             *ifp;
  34.     hashinfo         colorhashtable[HASHSIZE];
  35.     struct hashinfo  *hashrun;
  36.     pixel            *xP;
  37.     int              argn;
  38.     int              dpi300=FALSE;
  39.     int              cols, rows, format, col, row;
  40.     int              sharpness, enlarge, copy, tiny;
  41.     pixval           maxval;
  42.     struct mediasize medias;
  43.     char             media[16];
  44.     char *usage = "[-sharpness <1-4>] [-enlarge <1-3>] [-media <a,a4,as,a4s>] [-copy <1-9>] [-tiny] [-dpi300] [ppmfile]";
  45.  
  46.     ppm_init(&argc, argv);
  47.  
  48.     argn = 1;
  49.     sharpness = 32;
  50.     enlarge   = 1;
  51.     copy      = 1;
  52.     memset(media, '\0', 16);
  53.     tiny      = FALSE;
  54.  
  55.     /* check for flags */
  56.     while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') {
  57.     if (pm_keymatch(argv[argn], "-sharpness", 2)) {
  58.         ++argn;
  59.         if (argn == argc || sscanf(argv[argn], "%d", &sharpness) != 1)
  60.             pm_usage(usage);
  61.         else if (sharpness < 1 || sharpness > 4)
  62.             pm_usage(usage);
  63.         }
  64.     else if (pm_keymatch(argv[argn], "-enlarge", 2)) {
  65.         ++argn;
  66.         if (argn == argc || sscanf(argv[argn], "%d", &enlarge) != 1)
  67.             pm_usage(usage);
  68.         else if (enlarge < 1 || enlarge > 3)
  69.             pm_usage(usage);
  70.         }
  71.     else if (pm_keymatch(argv[argn], "-media", 2)) {
  72.         ++argn;
  73.         if (argn == argc || sscanf(argv[argn], "%s", media) < 1)
  74.             pm_usage(usage);
  75.         else if (mytoupper(media[0]) != 'A')
  76.             pm_usage(usage);
  77.     }
  78.     else if (pm_keymatch(argv[argn], "-copy", 2)) {
  79.         ++argn;
  80.         if (argn == argc || sscanf(argv[argn], "%d", ©) != 1)
  81.             pm_usage(usage);
  82.         else if (copy < 1 || copy > 9)
  83.             pm_usage(usage);
  84.         }
  85.     else if (pm_keymatch(argv[argn], "-dpi300", 2))
  86.         dpi300 = TRUE;
  87.     else if (pm_keymatch(argv[argn], "-tiny", 2))
  88.         tiny = TRUE;
  89.     else
  90.         pm_usage(usage);
  91.         ++argn;
  92.     }
  93.  
  94.     if (argn < argc) {
  95.         ifp = pm_openr(argv[argn]);
  96.         ++argn;
  97.     }
  98.     else
  99.         ifp = stdin;
  100.  
  101.     if (argn != argc)
  102.         pm_usage(usage);
  103.  
  104.     if (mytoupper(media[0]) == 'A')
  105.         switch (mytoupper(media[1])) {
  106.         case 'S':
  107.             medias = MSize_AS;
  108.             break;
  109.         case '4':
  110.             if(mytoupper(media[2]) == 'S')
  111.                 medias = MSize_A4S;
  112.             else {
  113.                 medias = MSize_A4;
  114.             }
  115.             break;
  116.         default:
  117.             medias = MSize_A;
  118.         }
  119.     else
  120.         medias = MSize_User;
  121.  
  122.     if (dpi300) {
  123.         medias.maxcols *= 2;
  124.         medias.maxrows *= 2;
  125.     }
  126.  
  127.     if (tiny) {
  128.         pixel            *pixelrow;
  129.         char             *redrow, *greenrow, *bluerow;
  130.  
  131.         ppm_readppminit(ifp, &cols, &rows, &maxval, &format);
  132.         pixelrow = (pixel *) ppm_allocrow(cols);
  133.         if ((redrow = malloc(cols * sizeof(char))) == NULL) {
  134.             fprintf(stderr, "ppmtomitsu: malloc failed, exiting\n");
  135.             exit(1);
  136.         }
  137.         if ((greenrow = malloc( cols * sizeof(char))) == NULL) {
  138.             fprintf(stderr, "ppmtomitsu: malloc failed, exiting\n");
  139.             exit(1);
  140.         }
  141.         if ((bluerow = malloc( cols * sizeof(char))) == NULL) {
  142.             fprintf(stderr, "ppmtomitsu: malloc failed, exiting\n");
  143.             exit(1);
  144.         }
  145.         lineputinit(cols, rows, sharpness, enlarge, copy, medias);
  146.  
  147.         for ( row = 0; row < rows; ++row ) {
  148.             ppm_readppmrow(ifp, pixelrow, cols, maxval, format);
  149.             switch(PPM_FORMAT_TYPE(format)) {
  150.             /* color */
  151.             case PPM_TYPE:
  152.                 for (col = 0, xP = pixelrow; col < cols; col++, xP++) {
  153.                     /* First red. */
  154.                     redrow[col] = PPM_GETR(*xP);
  155.                     /* Then green. */
  156.                     greenrow[col] = PPM_GETG(*xP);
  157.                     /* And blue. */
  158.                     bluerow[col] = PPM_GETB(*xP);
  159.                 }
  160.                 data(redrow,   cols);
  161.                 data(greenrow, cols); 
  162.                 data(bluerow,  cols);
  163.                 break;
  164.             /* grayscale */
  165.             default:
  166.                 for (col = 0, xP = pixelrow; col < cols; col++, xP++)
  167.                     bluerow[col] = PPM_GETB(*xP);
  168.                 data(bluerow, cols);
  169.                 data(bluerow, cols);
  170.                 data(bluerow, cols);
  171.                 break;
  172.             }
  173.         }
  174.         pm_close(ifp);
  175.     }
  176.     else {
  177.         pixel            **pixelpic;
  178.         int              colanz, colval;
  179.         int                 i;
  180.         colorhist_vector table;
  181.  
  182.         ppm_readppminit( ifp, &cols, &rows, &maxval, &format );
  183.         pixelpic = ppm_allocarray( cols, rows );
  184.         for (row = 0; row < rows; row++)
  185.             ppm_readppmrow( ifp, pixelpic[row], cols, maxval, format );
  186.         pm_close(ifp);
  187.  
  188.         /* first check wether we can use the lut transfer */
  189.  
  190.         table = ppm_computecolorhist(pixelpic, cols, rows, MAXLUTCOL+1, &colanz);
  191.         if (table != NULL) {
  192.             for (i=0; i<HASHSIZE; i++) {
  193.                 colorhashtable[i].flag = -1;
  194.                 colorhashtable[i].next = NULL;
  195.             }
  196.  
  197.             /* we can use the lookuptable */
  198.             pm_message("found %d colors - using the lookuptable-method",colanz);
  199.             lookuptableinit(sharpness, enlarge, copy, medias);
  200.             switch(PPM_FORMAT_TYPE(format)) {
  201.             /* color */
  202.             case PPM_TYPE:
  203.                 for (colval=0; colval<colanz; colval++) {
  204.                     cmd('$');
  205.                     datum(colval);
  206.                     datum(PPM_GETR((table[colval]).color));
  207.                     datum(PPM_GETG((table[colval]).color));
  208.                     datum(PPM_GETB((table[colval]).color));
  209.                     
  210.                     hashrun = &colorhashtable[myhash((table[colval]).color)];
  211.                     if (hashrun->flag == -1) {
  212.                         hashrun->color = (table[colval]).color;
  213.                         hashrun->flag  = colval;
  214.                     }
  215.                     else {
  216.                         while (hashrun->next != NULL)
  217.                             hashrun = hashrun->next;
  218.                         if ((hashrun->next = 
  219.                         (struct hashinfo *) malloc(sizeof(struct hashinfo)))
  220.                                                                 == NULL) {
  221.                             fprintf(stderr, "%s: malloc failed, exiting\n",
  222.                                 argv[0]);
  223.                             exit(2);
  224.                         }
  225.                         hashrun = hashrun->next;
  226.                         hashrun->color = (table[colval]).color;
  227.                         hashrun->flag  = colval;
  228.                         hashrun->next  = NULL;
  229.                     }
  230.                 }
  231.                 break;
  232.             /* other */
  233.             default:
  234.                 for (colval=0; colval<colanz; colval++) {
  235.                     cmd('$');
  236.                     datum(colval);
  237.                     datum(PPM_GETB((table[colval]).color));
  238.                     datum(PPM_GETB((table[colval]).color));
  239.                     datum(PPM_GETB((table[colval]).color));
  240.                     
  241.                     hashrun = &colorhashtable[myhash((table[colval]).color)];
  242.                     if (hashrun->flag == -1) {
  243.                         hashrun->color = (table[colval]).color;
  244.                         hashrun->flag  = colval;
  245.                     }
  246.                     else {
  247.                         while (hashrun->next != NULL)
  248.                             hashrun = hashrun->next;
  249.                         if ((hashrun->next = 
  250.                         (struct hashinfo *) malloc(sizeof(struct hashinfo)))
  251.                                                                 == NULL) {
  252.                             fprintf(stderr, "%s: malloc failed, exiting\n",
  253.                                 argv[0]);
  254.                             exit(2);
  255.                         }
  256.                         hashrun = hashrun->next;
  257.                         hashrun->color = (table[colval]).color;
  258.                         hashrun->flag  = colval;
  259.                         hashrun->next  = NULL;
  260.                     }
  261.                 }
  262.             }
  263.             lookuptabledata(cols, rows, enlarge, medias);
  264.             for (row=0; row<rows; row++) {
  265.                 xP = pixelpic[row];
  266.                 for (col=0; col<cols; col++, xP++) {
  267.                     hashrun = &colorhashtable[myhash(*xP)];
  268.                     while (!PPM_EQUAL((hashrun->color), *xP))
  269.                         if (hashrun->next != NULL)
  270.                             hashrun = hashrun->next;
  271.                         else {
  272.                             fprintf(stderr, "%s: you just found a letal bug.\n",
  273.                                 argv[0]);
  274.                             exit(1);
  275.                         }
  276.                     datum(hashrun->flag);
  277.                 }
  278.             }
  279.         }
  280.         else {
  281.         /* $#%@^!& no lut possible, so send the pic as 24bit */
  282.             pm_message("found too many colors for fast lookuptable mode");
  283.             frametransferinit(cols, rows, sharpness, enlarge, copy, medias);
  284.             switch(PPM_FORMAT_TYPE(format)) {
  285.             /* color */
  286.             case PPM_TYPE:
  287.                 COLORDES(RED);
  288.                 DATASTART;                    /* red coming */
  289.                 for (row=0; row<rows; row++) {
  290.                     xP = pixelpic[row];
  291.                     for (col=0; col<cols; col++, xP++)
  292.                         datum(PPM_GETR(*xP));
  293.                 }
  294.                 COLORDES(GREEN);
  295.                 DATASTART;                    /* green coming */
  296.                 for (row=0; row<rows; row++) {
  297.                     xP = pixelpic[row];
  298.                     for (col=0; col<cols; col++, xP++)
  299.                         datum(PPM_GETG(*xP));
  300.                 }
  301.                 COLORDES(BLUE);
  302.                 DATASTART;                    /* blue coming */
  303.                 for (row=0; row<rows; row++) {
  304.                     xP = pixelpic[row];
  305.                     for (col=0; col<cols; col++, xP++)
  306.                         datum(PPM_GETB(*xP));
  307.                 }
  308.                 break;
  309.             /* grayscale */
  310.             default:
  311.                 COLORDES(RED);
  312.                 DATASTART;                    /* red coming */
  313.                 for (row=0; row<rows; row++) {
  314.                     xP = pixelpic[row];
  315.                     for (col=0; col<cols; col++, xP++)
  316.                         datum(PPM_GETB(*xP));
  317.                 }
  318.                 COLORDES(GREEN);
  319.                 DATASTART;                    /* green coming */
  320.                 for (row=0; row<rows; row++) {
  321.                     xP = pixelpic[row];
  322.                     for (col=0; col<cols; col++, xP++)
  323.                         datum(PPM_GETB(*xP));
  324.                 }
  325.                 COLORDES(BLUE);
  326.                 DATASTART;                    /* blue coming */
  327.                 for (row=0; row<rows; row++) {
  328.                     xP = pixelpic[row];
  329.                     for (col=0; col<cols; col++, xP++)
  330.                         datum(PPM_GETB(*xP));
  331.                 }
  332.             }
  333.         }
  334.     }
  335.     PRINTIT;
  336.     exit(0);
  337. }
  338.  
  339. #ifdef __STDC__
  340. static void lineputinit(int cols, int rows, 
  341.                         int sharpness, int enlarge, int copy,
  342.                         struct mediasize medias)
  343. #else /*__STDC__*/
  344. static int lineputinit(cols, rows, sharpness, enlarge, copy, medias)
  345.     int cols, rows;
  346.     int sharpness, enlarge, copy;
  347.     struct mediasize medias;
  348. #endif /*__STDC__*/
  349. {
  350.     ONLINE;
  351.     CLRMEM;
  352.     MEDIASIZE(medias);
  353.  
  354.     switch (enlarge) {
  355.     case 2:
  356.         HENLARGE(ENLARGEx2); /* enlarge horizontal */
  357.         VENLARGE(ENLARGEx2); /* enlarge vertical */
  358.         break;
  359.     case 3:
  360.         HENLARGE(ENLARGEx3); /* enlarge horizontal */
  361.         VENLARGE(ENLARGEx3); /* enlarge vertical */
  362.         break;
  363.     default:
  364.         HENLARGE(NOENLARGE); /* enlarge horizontal */
  365.         VENLARGE(NOENLARGE); /* enlarge vertical */
  366.     }
  367.  
  368.     COLREVERSION(DONTREVERTCOLOR);
  369.     NUMCOPY(copy);
  370.  
  371.     HOFFINCH('\000');
  372.     VOFFINCH('\000');
  373.     CENTERING(DONTCENTER);
  374.  
  375.     TRANSFERFORMAT(LINEORDER);
  376.     COLORSYSTEM(RGB);
  377.     GRAYSCALELVL(BIT_8);
  378.     
  379.     switch (sharpness) {          /* sharpness :-) */
  380.     case 0:
  381.         SHARPNESS(SP_NONE);
  382.         break;
  383.     case 1:
  384.         SHARPNESS(SP_LOW);
  385.         break;
  386.     case 2:
  387.         SHARPNESS(SP_MIDLOW);
  388.         break;
  389.     case 3:
  390.         SHARPNESS(SP_MIDHIGH);
  391.         break;
  392.     case 4:
  393.         SHARPNESS(SP_HIGH);
  394.         break;
  395.     default:
  396.         SHARPNESS(SP_USER);
  397.     }
  398.     if (cols > rows) {
  399.         ROTATEIMG(DOROTATE);                        /* rotate image */
  400.         if (enlarge*rows > medias.maxcols || enlarge*cols > medias.maxrows) {
  401.             fprintf(stderr, "ppmtomitsu: Image too large, MaxPixels = %d x %d\n"
  402.                           , medias.maxrows, medias.maxcols);
  403.             exit(1);
  404.         }
  405.         HPIXELS(cols);
  406.         VPIXELS(rows);
  407.         HPIXELSOFF((medias.maxcols/enlarge - rows)/2);
  408.         VPIXELSOFF((medias.maxrows/enlarge - cols)/2);
  409.         pm_message("rotating image for output");
  410.     }
  411.     else {
  412.         ROTATEIMG(DONTROTATE);
  413.         if (enlarge*rows > medias.maxrows || enlarge*cols > medias.maxcols) {
  414.             fprintf(stderr, "ppmtomitsu: Image too large, MaxPixels = %d x %d\n"
  415.                           , medias.maxrows, medias.maxcols);
  416.             exit(1);
  417.         }
  418.         HPIXELS(cols);
  419.         VPIXELS(rows);
  420.         HPIXELSOFF((medias.maxcols/enlarge - cols)/2);
  421.         VPIXELSOFF((medias.maxrows/enlarge - rows)/2);
  422.     }
  423.     DATASTART;
  424.     return;
  425. }
  426.  
  427. #ifdef __STDC__
  428. static void lookuptableinit(int sharpness, int enlarge, int copy,
  429.                             struct mediasize medias)
  430. #else /*__STDC__*/
  431. static int lookuptableinit(sharpness, enlarge, copy, medias)
  432.     int sharpness, enlarge, copy;
  433.     struct mediasize medias;
  434. #endif /*__STDC__*/
  435. {
  436.     ONLINE;
  437.     CLRMEM;
  438.     MEDIASIZE(medias);
  439.  
  440.     switch (enlarge) {
  441.     case 2:
  442.         HENLARGE(ENLARGEx2); /* enlarge horizontal */
  443.         VENLARGE(ENLARGEx2); /* enlarge vertical */
  444.         break;
  445.     case 3:
  446.         HENLARGE(ENLARGEx3); /* enlarge horizontal */
  447.         VENLARGE(ENLARGEx3); /* enlarge vertical */
  448.         break;
  449.     default:
  450.         HENLARGE(NOENLARGE); /* enlarge horizontal */
  451.         VENLARGE(NOENLARGE); /* enlarge vertical */
  452.     }
  453.  
  454.     COLREVERSION(DONTREVERTCOLOR);
  455.     NUMCOPY(copy);
  456.  
  457.     HOFFINCH('\000');
  458.     VOFFINCH('\000');
  459.     CENTERING(DONTCENTER);
  460.  
  461.     TRANSFERFORMAT(LOOKUPTABLE);
  462.     
  463.     switch (sharpness) {          /* sharpness :-) */
  464.     case 0:
  465.         SHARPNESS(SP_NONE);
  466.         break;
  467.     case 1:
  468.         SHARPNESS(SP_LOW);
  469.         break;
  470.     case 2:
  471.         SHARPNESS(SP_MIDLOW);
  472.         break;
  473.     case 3:
  474.         SHARPNESS(SP_MIDHIGH);
  475.         break;
  476.     case 4:
  477.         SHARPNESS(SP_HIGH);
  478.         break;
  479.     default:
  480.         SHARPNESS(SP_USER);
  481.     }
  482.  
  483.     LOADLOOKUPTABLE;
  484.     return;
  485. }
  486.  
  487. #ifdef __STDC__
  488. static void lookuptabledata(int cols, int rows, int enlarge,
  489.                                                         struct mediasize medias)
  490. #else /*__STDC__*/
  491. static int lookuptabledata(cols, rows, enlarge, medias)
  492.     int   rows, cols;
  493.     int   enlarge;
  494.     struct mediasize medias;
  495. #endif /*__STDC__*/
  496. {
  497.     DONELOOKUPTABLE;
  498.     if (cols > rows) {
  499.         ROTATEIMG(DOROTATE);                        /* rotate image */
  500.         if (enlarge*rows > medias.maxcols || enlarge*cols > medias.maxrows) {
  501.             fprintf(stderr, "ppmtomitsu: Image too large, MaxPixels = %d x %d\n"
  502.                           , medias.maxrows, medias.maxcols);
  503.             exit(1);
  504.         }
  505.         HPIXELS(cols);
  506.         VPIXELS(rows);
  507.         HPIXELSOFF((medias.maxcols/enlarge - rows)/2);
  508.         VPIXELSOFF((medias.maxrows/enlarge - cols)/2);
  509.         pm_message("rotating image for output");
  510.     }
  511.     else {
  512.         ROTATEIMG(DONTROTATE);
  513.         if (enlarge*rows > medias.maxrows || enlarge*cols > medias.maxcols) {
  514.             fprintf(stderr, "ppmtomitsu: Image too large, MaxPixels = %d x %d\n"
  515.                           , medias.maxrows, medias.maxcols);
  516.             exit(1);
  517.         }
  518.         HPIXELS(cols);
  519.         VPIXELS(rows);
  520.         HPIXELSOFF((medias.maxcols/enlarge - cols)/2);
  521.         VPIXELSOFF((medias.maxrows/enlarge - rows)/2);
  522.     }
  523.     DATASTART;
  524.     return;
  525. }
  526.  
  527. #ifdef __STDC__
  528. static void frametransferinit(int cols, int rows, int sharpness,
  529.                               int enlarge, int copy, struct mediasize medias)
  530. #else
  531. static int frametransferinit(cols, rows, sharpness, enlarge, copy, medias)
  532.  
  533.     int     rows, cols;
  534.     int     sharpness, enlarge, copy;
  535.     struct mediasize medias;
  536. #endif
  537. {
  538.     ONLINE;
  539.     CLRMEM;
  540.     MEDIASIZE(medias);
  541.  
  542.     switch (enlarge) {
  543.     case 2:
  544.         HENLARGE(ENLARGEx2); /* enlarge horizontal */
  545.         VENLARGE(ENLARGEx2); /* enlarge vertical */
  546.         break;
  547.     case 3:
  548.         HENLARGE(ENLARGEx3); /* enlarge horizontal */
  549.         VENLARGE(ENLARGEx3); /* enlarge vertical */
  550.         break;
  551.     default:
  552.         HENLARGE(NOENLARGE); /* enlarge horizontal */
  553.         VENLARGE(NOENLARGE); /* enlarge vertical */
  554.     }
  555.  
  556.     COLREVERSION(DONTREVERTCOLOR);
  557.     NUMCOPY(copy);
  558.  
  559.     HOFFINCH('\000');
  560.     VOFFINCH('\000');
  561.     CENTERING(DONTCENTER);
  562.  
  563.     TRANSFERFORMAT(FRAMEORDER);
  564.     COLORSYSTEM(RGB);
  565.     GRAYSCALELVL(BIT_8);
  566.     
  567.     switch (sharpness) {          /* sharpness :-) */
  568.     case 0:
  569.         SHARPNESS(SP_NONE);
  570.         break;
  571.     case 1:
  572.         SHARPNESS(SP_LOW);
  573.         break;
  574.     case 2:
  575.         SHARPNESS(SP_MIDLOW);
  576.         break;
  577.     case 3:
  578.         SHARPNESS(SP_MIDHIGH);
  579.         break;
  580.     case 4:
  581.         SHARPNESS(SP_HIGH);
  582.         break;
  583.     default:
  584.         SHARPNESS(SP_USER);
  585.     }
  586.     if (cols > rows) {
  587.         ROTATEIMG(DOROTATE);                        /* rotate image */
  588.         if (enlarge*rows > medias.maxcols || enlarge*cols > medias.maxrows) {
  589.             fprintf(stderr, "ppmtomitsu: Image too large, MaxPixels = %d x %d\n"
  590.                           , medias.maxrows, medias.maxcols);
  591.             exit(1);
  592.         }
  593.         HPIXELS(cols);
  594.         VPIXELS(rows);
  595.         HPIXELSOFF((medias.maxcols/enlarge - rows)/2);
  596.         VPIXELSOFF((medias.maxrows/enlarge - cols)/2);
  597.         pm_message("rotating image for output");
  598.     }
  599.     else {
  600.         ROTATEIMG(DONTROTATE);
  601.         if (enlarge*rows > medias.maxrows || enlarge*cols > medias.maxcols) {
  602.             fprintf(stderr, "ppmtomitsu: Image too large, MaxPixels = %d x %d\n"
  603.                           , medias.maxrows, medias.maxcols);
  604.             exit(1);
  605.         }
  606.         HPIXELS(cols);
  607.         VPIXELS(rows);
  608.         HPIXELSOFF((medias.maxcols/enlarge - cols)/2);
  609.         VPIXELSOFF((medias.maxrows/enlarge - rows)/2);
  610.     }
  611.     return;
  612. }
  613.